package project.view;

import java.util.GregorianCalendar;

import project.controllers.sort.SortBy;
import project.controllers.sort.SortObjectBy;
import project.controllers.workers.DBManager;
import project.model.IGarage;
import project.model.IMaster;
import project.model.IOrder;
import project.model.OrderStatus;

public class Autoservice {

	private DBManager dbm;

	public Autoservice(String masPath, String ordPath, String garPath) {
		dbm = new DBManager(masPath, ordPath, garPath);
	}

	public void getEmptyGarage() {
		dbm.getEmptyGarage();
	}

	public void SortOrderByBeginningDate() {
		dbm.SortOrder(SortBy.SortBy(SortObjectBy.SORT_ORDERS_BY_BEGINING_DATE));
	}

	public void SortOrderByDeadlineDate() {
		dbm.SortOrder(SortBy.SortBy(SortObjectBy.SORT_ORDERS_BY_DEADLINE_DATE));
	}

	public void SortOrderByFillingDate() {
		dbm.SortOrder(SortBy.SortBy(SortObjectBy.SORT_ORDERS_BY_FILLING_DATE));
	}

	public void SortOrderByPrice() {
		dbm.SortOrder(SortBy.SortBy(SortObjectBy.SORT_ORDERS_BY_PRICE));
	}

	public void SortMasterByEmployment() {
		dbm.SortMaster(SortBy.SortBy(SortObjectBy.SORT_MASTER_BY_EMPLOYMENT));
	}

	public void SortMasterByName() {
		dbm.SortMaster(SortBy.SortBy(SortObjectBy.SORT_MASTER_BY_NAME));
	}

	public void SortMadingOrderByBeginningDate() {
		dbm.SortMadingOrder(SortBy
				.SortBy(SortObjectBy.SORT_ORDERS_BY_BEGINING_DATE));

	}

	public void SortMadingOrderByDeadlineDate() {
		dbm.SortMadingOrder(SortBy
				.SortBy(SortObjectBy.SORT_ORDERS_BY_DEADLINE_DATE));
	}

	public void SortMadingOrderByFillinggDate() {
		dbm.SortMadingOrder(SortBy
				.SortBy(SortObjectBy.SORT_ORDERS_BY_FILLING_DATE));

	}

	public void SortMadingOrderByPrice() {
		dbm.SortMadingOrder(SortBy.SortBy(SortObjectBy.SORT_ORDERS_BY_PRICE));

	}

	public void getOrderByMaster(IMaster master) {
		dbm.getOrdersByMaster(master);
	}

	public void getMasterByOrder(IOrder order) {
		dbm.getMastersByOrder(order);
	}


	public void SortOrderByPeriodByBeginningDate(OrderStatus ordSt,
			GregorianCalendar begin, GregorianCalendar end) {
		dbm.SortOrderByPeriod(ordSt, SortBy.SortBy(SortObjectBy.SORT_ORDERS_BY_BEGINING_DATE), begin, end);
	}
	
	public void SortOrderByPeriodByDeadlineDate(OrderStatus ordSt,
			GregorianCalendar begin, GregorianCalendar end) {
		dbm.SortOrderByPeriod(ordSt, SortBy.SortBy(SortObjectBy.SORT_ORDERS_BY_DEADLINE_DATE), begin, end);
	}
	
	public void SortOrderByPeriodByFillingDate(OrderStatus ordSt,
			GregorianCalendar begin, GregorianCalendar end) {
		dbm.SortOrderByPeriod(ordSt, SortBy.SortBy(SortObjectBy.SORT_ORDERS_BY_FILLING_DATE), begin, end);
	}
	
	public void SortOrderByPeriodByPrice(OrderStatus ordSt,
			GregorianCalendar begin, GregorianCalendar end) {
		dbm.SortOrderByPeriod(ordSt, SortBy.SortBy(SortObjectBy.SORT_ORDERS_BY_PRICE), begin, end);
	}
	
	

	public void getFreePlacesOnDate(GregorianCalendar date) {
		dbm.getNumberEmptyPlaces(date);
	}

	public void getNextFreeDate() {
		dbm.getNextFreeDate();
	}

	public void addMaster(IMaster master) {
		dbm.addMaster(master);
	}

	public void deleteMaster(IMaster master) {
		dbm.deleteMaster(master);
	}

	public void addGarage(IGarage garage) {
		dbm.addGarage(garage);
	}

	public void deleteGarage(IGarage garage) {
		dbm.deleteGarage(garage);
	}

	public void addOrder(IOrder order) {
		dbm.addOrder(order);
	}

	public void markOrder(OrderStatus ordSt, IOrder order,
			GregorianCalendar nowDate) {
		dbm.markOrder(ordSt, order, nowDate);
	}

	public void ShirtTimeOrder(GregorianCalendar newDate, IOrder order) {
		dbm.ShirtTimeOrder(newDate, order);
	}

	public void resaveData() {
		dbm.saveData();
	}

}
